<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8" />
<script type="text/javascript">
goodnum=0;
$(document).ready(function(){
	$("#logout").click(function(){
		$.ajax({
			type:"POST",
			url:"login/logout.php",
			success:function(data){
				if(data==1)
					window.location.reload();
				}
			});
		});
	$(".add").click(function(){
		$.ajax({
			type:"POST",
			url:"<?php echo CHtml::normalizeUrl(array('Yiichenkuo/addshopcar'));?>",
			data:{shopid:$(this).attr("id")},
			error:function(){
				alert("错误");
				},
			success:function(data){
				if(data==1)
				{
				alert("添加购物车成功");
				goodnum++;
				$("#shopcar").replaceWith("<a href=\'Yiichenkuo/shopcar\' id=\'shopcar\' >购物车"+goodnum+"</a>");
				}
				if(data==2)
				alert("你还没有登录");
				if(data==3)
					alert("你没有添加成功");
				}			
			});
		});
});
</script>
</head>
<a href="<?php echo $this->createUrl("Yiichenkuo/shopcar",array("userid"=>Yii::app()->user->getName()));?>">购物车</a>
<?php
echo "Yiichenkuo/index.php"."</br>";?>
<?php foreach ($model as $key=>$value):?>
	<div>
		<p>名称 : <?php echo $value['shopname']?></p>
		<p>简介:<?php echo $value['shopdescription']?></p>
		<p><input type="button" class="add" id="<?php echo $value['shopid']?>" value="加入购物车"></p>
	</div>
<?php endforeach;?>

</html>